package org.kuan.lab.common.entity;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import javax.persistence.AttributeOverride;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.TableGenerator;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

import org.kuan.lab.base.entity.BaseEntity;

/**
 * Project: erp<br>
 * Description: 用户实体表<br>
 * Copyright (c) 2012<br>
 * All Rights Reserved.<br>
 * @author <a href="mailto:gly420@163.com">GuanLuYong</a><br>
 */
@Entity
@Table(name = "ERP_USER", schema = "DEVA")
public class User extends BaseEntity implements Serializable {
	private static final long serialVersionUID = 1L;
	
//	@Id
//	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "ERP_USER_SEQ")
//	@SequenceGenerator(name="ERP_USER_SEQ", sequenceName="ERP_USER_SEQ", allocationSize=1, initialValue = 1000)
//	@AttributeOverride(column = @Column(name = "ID"), name = "id")
//	@Id
//	@GeneratedValue(strategy = GenerationType.TABLE, generator = "ERP_PKTABLES")
//	@TableGenerator(name = "ERP_PKTABLES", table = "ERP_PKTABLES", allocationSize = 1, initialValue = 1000,
//			schema = "DEVA", pkColumnName = "KEY_ID", valueColumnName = "KEY_VALUE", pkColumnValue = "USER_KEY_VALUE")
//	@Column(name = "ID", nullable = false, updatable = false)
//	protected Long id;
	
	@Column(name = "ACCOUNT", nullable = false, length = 50, unique = true)
	private String account;

	@Column(name = "PASSWORD", nullable = false, length = 50)
	private String password;

	@Column(name = "CODE", length = 50)
	private String code;
	
	@Column(name = "NAME", length = 20)
	private String name;
	
	@Column(name = "SEX", length = 1)
	private String sex;
	
	@Column(name = "BIRTH")
	@Temporal(TemporalType.TIMESTAMP)
	private Date birth;

	@Column(name = "MOBILE", length = 50)
	private String mobile;
	
	@Column(name = "TELEPHONE", length = 50)
	private String telephone;

	@Column(name = "HEAD_IMG", length = 100)
	private String headImg;
	
	@Column(name = "CARD_NO", length = 30)
	private String card;
	
	@Column(name = "QQ_NO", length = 30)
	private String qq;
	
	@Column(name = "MSN_NO", length = 100)
	private String msn;
	
	@Column(name = "EMAIL", length = 120)
	private String email;
	
	@Column(name = "ZIP_CODE", length = 10)
	private String zip;
	
	@Column(name = "ADDRESS", length = 250)
	private String address;
	
	@OneToMany(mappedBy = "user")
	private List<UserResource> userResources;
	
	@OneToMany(mappedBy = "user")
	private List<UserRole> userRoles;
	
	@Transient
	private String validPassword;
	
	// Getter & Setter
	public String getAccount() {
		return account;
	}
	
	public void setAccount(String account) {
		this.account = account;
	}
	
	public String getPassword() {
		return password;
	}
	
	public void setPassword(String password) {
		this.password = password;
	}
	
	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getName() {
		return name;
	}
	
	public void setName(String name) {
		this.name = name;
	}
	
	public String getSex() {
		return sex;
	}
	
	public void setSex(String sex) {
		this.sex = sex;
	}
	
	public Date getBirth() {
		return birth;
	}
	
	public void setBirth(Date birth) {
		this.birth = birth;
	}
	
	public String getMobile() {
		return mobile;
	}
	
	public void setMobile(String mobile) {
		this.mobile = mobile;
	}
	
	public String getTelephone() {
		return telephone;
	}
	
	public void setTelephone(String telephone) {
		this.telephone = telephone;
	}
	
	public String getHeadImg() {
		return headImg;
	}
	
	public void setHeadImg(String headImg) {
		this.headImg = headImg;
	}
	
	public String getCard() {
		return card;
	}

	public void setCard(String card) {
		this.card = card;
	}

	public String getQq() {
		return qq;
	}
	
	public void setQq(String qq) {
		this.qq = qq;
	}
	
	public String getMsn() {
		return msn;
	}
	
	public void setMsn(String msn) {
		this.msn = msn;
	}
	
	public String getEmail() {
		return email;
	}
	
	public void setEmail(String email) {
		this.email = email;
	}
	
	public String getZip() {
		return zip;
	}
	
	public void setZip(String zip) {
		this.zip = zip;
	}
	
	public String getAddress() {
		return address;
	}
	
	public void setAddress(String address) {
		this.address = address;
	}

	public String getValidPassword() {
		return validPassword;
	}

	public void setValidPassword(String validPassword) {
		this.validPassword = validPassword;
	}

	public List<UserResource> getUserResources() {
		return userResources;
	}

	public void setUserResources(List<UserResource> userResources) {
		this.userResources = userResources;
	}

	public List<UserRole> getUserRoles() {
		return userRoles;
	}

	public void setUserRoles(List<UserRole> userRoles) {
		this.userRoles = userRoles;
	}

}